<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>ajax 投票</title>
    <script>
        function getVote(int){
            if(window.XMLHttpRequest){
                xmlhttp=new XMLHttpRequest();
            }else{
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function(){
                if(xmlhttp.readyState==4 && xmlhttp.status==200){
                    document.getElementById("poll").innerHTML=xmlhttp.responseText;
                }
            }
            xmlhttp.open("GET","poll_vote.php?vote="+int,true);
            xmlhttp.send();
        }
    </script>
</head>
<body>
<div id="poll">
    <h3>do you like PHP and AJAX so far？</h3>
    <form>
        YES:
        <input type="radio" name="vote" value="0" onclick="getVote(this.value)"><br>
        NO:
        <input type="radio" name="vote" value="1" onclick="getVote(this.value)"><br>
    </form>
</div>
</body>
</html>